home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / gamesmaster / demosrc / c / doublebuffer / doublebuffer.c < prev    next >
C/C++ Source or Header  |  1996-07-16  |  3KB  |  90 lines

  1. /*
  2. ** Double Buffer Demo
  3. ** ------------------
  4. ** This just shows how to double buffer the screen.
  5. **
  6. ** Compiles under SAS/C.
  7. */
  8.  
  9. #include <stdio.h>
  10. #include <stdlib.h>
  11.  
  12. #include <exec/types.h>
  13. #include <exec/memory.h>
  14. #include <games/games.h>
  15. #include <games/gamesbase.h>
  16. #include <proto/games.h>
  17. #include <proto/exec.h>
  18.  
  19. #define PicFile    "GAMESLIB:data/Pic320.pak"
  20. #define AMT_PLANES 5
  21.  
  22. struct GMSBase *GMSBase;
  23. APTR   PicMemBase;
  24.  
  25. UWORD ScreenPalette[] =
  26.       {
  27.       0x0000,0x0A77,0x0B88,0x0866,0x0A98,0x0877,0x0B99,0x0CBB,
  28.       0x0ABB,0x0CCC,0x0333,0x0554,0x0556,0x0665,0x0788,0x0222,
  29.       0x0466,0x0345,0x0677,0x0888,0x0234,0x0322,0x0844,0x0733,
  30.       0x0632,0x0955,0x09AA,0x0022,0x0832,0x0943,0x0DCC,0x0DDD
  31.       };
  32.  
  33. struct GameScreen TheScreen =
  34.      {
  35.      "GSV1",              /* Structure version */
  36.      0,0,0,               /* Screen Mem - 1,2,3 */
  37.      0,                   /* ScreenLink */
  38.      &ScreenPalette,      /* Address of the screen palette */
  39.      0,                   /* Address of a colourlist */
  40.      32,                  /* Amt of colours in palette */
  41.      256,320,320/8,       /* Screen Height, Width, Width/8 */
  42.      256,320,320/8,       /* Pic Height, Width, Width/8 */
  43.      AMT_PLANES,          /* Amt_Planes */
  44.      0,0,                 /* Top Of Screen, X/Y */
  45.      0,                   /* Scroll buffer in pixels/8 */
  46.      0,0,                 /* X/Y counters (for scrolling) */
  47.      DBLBUFFER|NOBURST,   /* Special attributes */
  48.      LORES,               /* Screen mode */
  49.      INTERLEAVED,         /* Screen type */
  50.      0,                   /* Screen Is Being Displayed? */
  51.      0,0                  /* Reserved area */
  52.      };
  53.  
  54. /*=========================================================================*/
  55.  
  56. void main(void)
  57. {
  58.    struct GamesLibrary *GMSBase = (struct GamesLibrary *)
  59.        OpenLibrary("games.library", 0);
  60.    if (GMSBase == NULL) exit(FALSE);
  61.  
  62.    SetUserPri();
  63.  
  64.    if (Add_Screen(&TheScreen) == NULL)
  65.       {
  66.         PicMemBase = QuickLoad (PicFile,0,MEMF_ANY);
  67.  
  68.         if (PicMemBase != NULL)
  69.            {
  70.              SmartUnpack(PicMemBase, (&TheScreen)->SS_MemPtr1, 0);
  71.              FreeMemBlock(PicMemBase);
  72.  
  73.              Show_Screen(&TheScreen);
  74.  
  75.              do
  76.               {
  77.                 Wait_OSVBL();
  78.                 SwapBuffers(&TheScreen);
  79.               }
  80.              while (!(Read_JoyStick(JPORT1) & JS_FIRE1));
  81.            };
  82.  
  83.         Delete_Screen(&TheScreen);
  84.       };
  85.    CloseLibrary((struct Library *)GMSBase);
  86. }
  87.  
  88. /*=========================================================================*/
  89.  
  90.